Essential Angular by Victor Savkin & Jeff Cross

Essential Angular by Victor Savkin & Jeff Cross

Author:Victor Savkin & Jeff Cross [Savkin, Victor]
Language: eng
Format: azw3
Tags: COM051260 - COMPUTERS / Programming Languages / JavaScript, COM060160 - COMPUTERS / Web / Web Programming, COM060180 - COMPUTERS / Web / Web Services & APIs
Publisher: Packt Publishing
Published: 2017-05-31T04:00:00+00:00


Now we can use both @Inject(ComponentReexportingItself) and @Inject('alias') to inject this component.

Overrides

The providers of the imported modules are merged with the target module's providers, left to right, that is, if multiple imported modules define the same provider, the last one wins.

@NgModule({

providers: [

{provide: 'token', useValue: 'A'}

]

})

class ModuleA {}

@NgModule({

providers: [

{provide: 'token', useValue: 'B'}

]

})

class ModuleB {}

@NgModule({

imports: [ModuleA, ModuleB]

})

class ModuleC {

constructor(@Inject('token') t: string) {

console.log(t); // will print 'B'

}

}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.